// https://leetcode-cn.com/problems/longest-common-prefix/
class Solution {
public:
    string Compare(string &a, string &b) {
        string ret = "";
        for (int i = 0; a[i]; i++) {
            if (i == b.size() || a[i] != b[i]) return ret;
            ret += a[i];
        }
        return ret;
    }

    string longestCommonPrefix(vector<string>& strs) {
        string ret = strs[0];
        for (int i = 1;i < strs.size(); i++) {
            ret = Compare(ret, strs[i]);
        }
        return ret;
    }
};
